<template>
  <router-view />
</template>
<script setup>
import { onMounted } from "vue";
import { ipc } from "@/utils/ipcRenderer";
import { ipcApiRoute } from "@/api";
import { message } from "ant-design-vue";

onMounted(() => {
  const loadingElement = document.getElementById("loadingPage");
  if (loadingElement) {
    loadingElement.remove();
  }
  // 避免重复监听, 或者将 on 功能写到一个统一的地方, 只加载一次
  ipc.removeAllListeners(ipcApiRoute.global.message);

  // 监听任务进度
  ipc.on(ipcApiRoute.global.message, (event, result) => {
    const { type, msg: msg } = result;
    switch (type) {
      case "error":
        message.error(msg);
        break;
      case "info":
        message.info(msg);
        break;
      case "success":
        message.success(msg);
        break;
      default:
        break;
    }
  });
});
</script>
<style lang="less"></style>
